package com.jo.interceptor;

import com.jo.advisor.Advice;
import com.jo.advisor.MethodBeforeAdvice;
import com.jo.invocation.MethodInvocation;

/**
 * before适配器，用于将before advise适配成MethodInterceptor
 * @author Jo
 * @date 2018/1/25
 */
public class BeforeMethodAdapter implements AdviseAdapter {

    @Override
    public boolean support(Advice advice) {
        return advice instanceof MethodBeforeAdvice;
    }

    @Override
    public MethodInterceptor convert(Advice advice) {
        return new BeforeMethodInterceptor((MethodBeforeAdvice) advice);
    }
}
